<template>
  <div>
    <a-row>
      <a-col :span="5">
        <a-card>
          <div class="titlesB">
            <img class="titleImg" src="./u22070.png">
            <span>尿液检测</span>
          </div>
          <a-row>
            <a-col :span="4">
              <p class="p1"><span>{{ Urinedata.shouldNum ? Urinedata.shouldNum : '0' }}</span>次</p>
              <p class="p1">应检测</p>
              <!-- <p class="p1">111{{ jsonParam }}</p> -->
            </a-col>
            <a-col :span="4">
              <p class="p1"><span>{{ Urinedata.actualNum ? Urinedata.actualNum : '0' }}</span>次</p>
              <p class="p1">实检测</p>
            </a-col>
            <a-col :span="4">
              <p class="p1"><span>{{ Urinedata.exemptNum ? Urinedata.exemptNum : '0' }}</span>次</p>
              <p class="p1">免除</p>
            </a-col>
            <a-col :span="4">
              <p class="p1"><span>{{ Urinedata.cancelNum ? Urinedata.cancelNum : '0' }}</span>次</p>
              <p class="p1">取消</p>
            </a-col>
            <a-col :span="4" style="width: 24%;margin-right: 0;">
              <p class="p1"><span>{{ Urinedata.ratio ? Urinedata.ratio : '0' }}</span>%</p>
              <p class="p1">平均完成率</p>
            </a-col>
          </a-row>
        </a-card>
      </a-col>
      <a-col :span="5">
        <a-card>
          <div class="titlesB">
            <img class="titleImg" src="./u22070.png">
            <span>毛发检测</span>
          </div>
          <a-row>
            <a-col :span="4">
              <p class="p1"><span>{{ Urinedata1.shouldNum ? Urinedata1.shouldNum:'0' }}</span>次</p>
              <p class="p1">应检测</p>
            </a-col>
            <a-col :span="4">
              <p class="p1"><span>{{ Urinedata1.actualNum ? Urinedata1.actualNum: '0' }}</span>次</p>
              <p class="p1">实检测</p>
            </a-col>
            <a-col :span="4">
              <p class="p1"><span>{{ Urinedata1.exemptNum ? Urinedata1.exemptNum:'0' }}</span>次</p>
              <p class="p1">免除</p>
            </a-col>
            <a-col :span="4">
              <p class="p1"><span>{{ Urinedata1.cancelNum ? Urinedata1.cancelNum:'0' }}</span>次</p>
              <p class="p1">取消</p>
            </a-col>
            <a-col :span="4" style="width: 24%;margin-right: 0;">
              <p class="p1"><span>{{ Urinedata1.ratio ? Urinedata1.ratio:'0' }}</span>次</p>
              <p class="p1">平均完成率</p>
            </a-col>
          </a-row>
        </a-card>
      </a-col>
      <a-col :span="5">
        <a-card>
          <div class="titlesB">
            <img class="titleImg" src="./u22070.png">
            <span>定期访谈</span>
          </div>
          <a-row>
            <a-col :span="4">
              <p class="p1"><span>{{ Interviewdata.shouldNum ? Interviewdata.shouldNum : '0' }}</span>次</p>
              <p class="p1">应访谈</p>
            </a-col>
            <a-col :span="4">
              <p class="p1"><span>{{ Interviewdata.actualNum ? Interviewdata.actualNum:'0' }}</span>次</p>
              <p class="p1">实访谈</p>
            </a-col>
            <a-col :span="4">
              <p class="p1"><span>{{ Interviewdata.exemptNum ? Interviewdata.exemptNum:'0' }}</span>次</p>
              <p class="p1">免除</p>
            </a-col>
            <a-col :span="4">
              <p class="p1"><span>{{ Interviewdata.cancelNum ? Interviewdata.cancelNum:'0' }}</span>次</p>
              <p class="p1">取消</p>
            </a-col>
            <a-col :span="4" style="width: 24%;margin-right: 0;">
              <p class="p1"><span>{{ Interviewdata.ratio ? Interviewdata.ratio:'0' }}</span>次</p>
              <p class="p1">平均完成率</p>
            </a-col>
          </a-row>
        </a-card>
      </a-col>
      <a-col :span="5" style="margin-right: 0;">
        <a-card>
          <div class="titlesB">
            <img class="titleImg" src="./u22070.png">
            <span>定期报告</span>
          </div>
          <a-row>
            <a-col :span="4">
              <p class="p1"><span>{{ Reportdata.shouldNum ? Reportdata.shouldNum:'0' }}</span>次</p>
              <p class="p1">应报告</p>
            </a-col>
            <a-col :span="4">
              <p class="p1"><span>{{ Reportdata.actualNum ? Reportdata.actualNum:'0' }}</span>次</p>
              <p class="p1">实报告</p>
            </a-col>
            <a-col :span="4">
              <p class="p1"><span>{{ Reportdata.cancelNum ? Reportdata.cancelNum:'0' }}</span>次</p>
              <p class="p1">取消</p>
            </a-col>
            <a-col :span="4" style="width: 24%;margin-right: 0;">
              <p class="p1"><span>{{ Reportdata.ratio ? Reportdata.ratio:'0' }}</span>次</p>
              <p class="p1">平均完成率</p>
            </a-col>
          </a-row>
        </a-card>
      </a-col>
    </a-row>
    <a-row>
      <a-col :span="5" style="margin-top:15px;">
        <a-card>
          <div class="titlesB">
            <img class="titleImg" src="./u22070.png">
            <span>签到</span>
          </div>

          <a-row>
            <a-col :span="4">
              <p class="p1"><span>{{ SignCountdata.shouldMonthSignInDays ? SignCountdata.shouldMonthSignInDays:'0' }}</span>次</p>
              <p class="p1">应签到</p>
            </a-col>
            <a-col :span="4">
              <p class="p1"><span>{{ SignCountdata.actMonthSignInDays ? SignCountdata.actMonthSignInDays:'0' }}</span>次</p>
              <p class="p1">实签到</p>
            </a-col>
            <a-col :span="4">
              <p class="p1"><span>{{ SignCountdata.exemptionDays ? SignCountdata.exemptionDays:'0' }}</span>次</p>
              <p class="p1">免除</p>
            </a-col>
            <a-col :span="4">
              <p class="p1"><span>{{ SignCountdata.missSignInDays ? SignCountdata.missSignInDays:'0' }}</span>次</p>
              <p class="p1">取消</p>
            </a-col>
            <a-col :span="4" style="width: 24%;margin-right: 0;">
              <p class="p1"><span>{{ SignCountdata.signInRate ? SignCountdata.signInRate:'0' }}</span>次</p>
              <p class="p1">平均签到率</p>
            </a-col>
          </a-row>
        </a-card>
      </a-col>
      <a-col :span="17" style="margin-top:15px;width: 74.3%;">
        <a-card>
          <div class="titlesB">
            <img class="titleImg" src="./u22070.png">
            <span>其它介入情况</span>
          </div><br>
          <p class="p2">请假次数 <span class="s1">{{ Otherdata.leaveNum ? Otherdata.leaveNum:'0' }}</span> 次；请假时长 <span class="s1">{{
    Otherdata.leaveTime ? Otherdata.leaveTime:'0'
}}</span>
            天能；接受救助帮扶 <span class="s1">{{ Otherdata.helpNum ?Otherdata.helpNum:'0' }}</span> 次；接受帮教谈心 <span class="s1">{{
    Otherdata.interviewNum ? Otherdata.interviewNum:'0'
}}</span> 次；接受心理咨询
            <span class="s1">{{ Otherdata.mentalityNum ? Otherdata.mentalityNum:'0' }}</span>
            次；接受法律援助 <span class="s1">{{ Otherdata.lawNum ? Otherdata.lawNum:'0' }}</span> 次；申请职业技能培训 <span class="s1">{{
    Otherdata.applyTrainNum ? Otherdata.applyTrainNum:'0'
}}</span> 次；参与职业技能培训
            <span class="s1">{{ Otherdata.joinTrainNum ? Otherdata.joinTrainNum:'0' }}</span> 次；
            提交就业意愿 <span class="s1">{{ Otherdata.submitAspirationNum ? Otherdata.submitAspirationNum:'0' }}</span> 次；就业安置 <span class="s1">{{
    Otherdata.placementNum ? Otherdata.placementNum:'0'
}}</span> 次；参与社区活动 <span class="s1">{{ Otherdata.communityActiveNum ? Otherdata.communityActiveNum:'0'
}}</span> 次；参与小组活动 <span class="s1">{{ Otherdata.groupActiveNum ? Otherdata.groupActiveNum:'0' }}</span> 次；服药 <span class="s1">{{
    Otherdata.takeMedicineNum ? Otherdata.takeMedicineNum:'0'
              }}</span> 次；
          </p>
        </a-card>
      </a-col>
    </a-row>
  </div>
</template>

<script>
import {
  assessStatisticalToUrine, assessStatisticalToInterview,
  assessStatisticalToReport, assessStatisticalToOther, personSignCount
} from '@/api/sjsk/estimate/list/index'
import * as caseEstimateApi from '@/api/sjsk/caseEstimate.js'
import * as clinicmanageServiceApi from '@/api/sjsk/clinicmanageService.js'
export default {
  props: {
    businessType: {
      type: [String, Number],
      required: 0
    },
    jsonParam: {
      type: Object
    },
  },
  data() {
    return {
      // Controldata:{},
      // jsonParamdata: {},
      querydata: {},
      // Signquerydata: {},
      // mfquerydata: {
      //   type: 3
      // },
      Urinedata: {},
      Interviewdata: {},
      Reportdata: {},
      Otherdata: {},
      Urinedata1: {},
      SignCountdata: {},
      loading: false,
    }
  },
  watch: {
    businessType: {
      immediate: true,
      deep: true,
      handler(val) {
        // console.log(this.businessType);
      }
    },
    async 'jsonParam.assessmentEndTime'(){
      // console.log(11);
      let { assessmentEndTime, assessmentStartTime, personId } = this.jsonParam
      this.querydata.assessEndTime = assessmentEndTime
      this.querydata.assessStartTime = assessmentStartTime
      this.querydata.sjskPersonId = personId
      this.querydata.signInEndTime = assessmentEndTime
      this.querydata.signInStartTime = assessmentStartTime

      clinicmanageServiceApi.getSignInList({pageNo: 1,pageSize: 10,identityCard:this.jsonParam.identification}).then((res) => {
          this.querydata.userId = res.result.records[0].userId
          this.querydata.caseNo = res.result.records[0].caseNo
      })

      if (this.businessType !=16 &&this.querydata.assessEndTime!=null&&
        this.querydata.assessStartTime!=null&&this.querydata.sjskPersonId!=null) { this.refreshTable() }
    },

    async 'jsonParam.realName'(val){
      await caseEstimateApi.getPersons({pageNo: 1,pageSize: 10,realName:val,spId:this.jsonParam.spId,identityCard:this.jsonParam.identityCard}).then((res) => {
        this.querydata.assessEndTime = res.result.records[0].evalEndTime
        this.querydata.assessStartTime = res.result.records[0].evalStartTime
        this.querydata.sjskPersonId = res.result.records[0].spId
        // this.mfquerydata = Object.assign(this.mfquerydata, this.querydata)
      })

      await clinicmanageServiceApi.getSignInList({pageNo: 1,pageSize: 10,identityCard:this.jsonParam.identityCard}).then((res) => {
        this.querydata.signInEndTime = this.querydata.assessEndTime
        this.querydata.signInStartTime = this.querydata.assessStartTime
        this.querydata.userId = res.result.records[0].userId
        this.querydata.caseNo = res.result.records[0].caseNo
      })

      if (this.businessType == 16&&this.querydata.assessEndTime != null&&this.querydata.assessStartTime != null&&this.querydata.sjskPersonId != null) { this.refreshTable() }
    },
  },
  created() {
    this.jsonParam = {}
  },
  async mounted() {
    // this.onQuery()
    // this.getData1()
    // console.log(this.pageFilter);
    // this.test()
    // this.refreshTable()
    // console.log(this.jieanquerydata);
    // this.jieanrefreshTable()
    // this.jsonParam = {}
  },
  // computed: {
  //   change() {
  //     this.jsonParam = {};
  //   },
  // },
  methods: {
    refreshTable() {
      this.loading = true
      // 尿液检测
      // let params = Object.assign({}, this.querydata, { type: 1 })
      assessStatisticalToUrine({...this.querydata,type:1}).then((res) => {
        if (res.success) {
          this.Urinedata = res.result ? res.result : {}
          this.loading = false
        } else {
          this.$message.warn(res.message)
          this.loading = false
        }
      })
        .catch((e) => {
          this.loading = false
          this.$message.warn('请求失败！')
        })

      // 毛发检测
      assessStatisticalToUrine({...this.querydata,type:3}).then((res) => {
        if (res.success) {
          this.Urinedata1 = res.result ? res.result : {}
          // this.Controldata.Urinedata1 = res.result ? res.result : {}
          this.loading = false
        } else {
          this.$message.warn(res.message)
          this.loading = false
        }
      })
        .catch((e) => {
          this.loading = false
          this.$message.warn('请求失败！')
        })

      // 定期访谈
      assessStatisticalToInterview(this.querydata).then((res) => {
        if (res.success) {
          this.Interviewdata = res.result ? res.result : {}
          this.loading = false
        } else {
          this.$message.warn(res.message)
          this.loading = false
        }
      })
        .catch((e) => {
          this.loading = false
          this.$message.warn('请求失败！')
        })

      // 定期报告
      assessStatisticalToReport(this.querydata).then((res) => {
        if (res.success) {
          this.Reportdata = res.result ? res.result : {}
          this.loading = false
        } else {
          this.$message.warn(res.message)
          this.loading = false
        }
      })
        .catch((e) => {
          this.loading = false
          this.$message.warn('请求失败！')
        })

      // 其他介入情况
      assessStatisticalToOther(this.querydata).then((res) => {
        if (res.success) {
          this.Otherdata = res.result ? res.result : {}
          this.loading = false
        } else {
          this.$message.warn(res.message)
          this.loading = false
        }
      })
        .catch((e) => {
          this.loading = false
          this.$message.warn('请求失败！')
        })

      // 签到
        personSignCount(this.querydata).then((res) => {
        if (res.success) {
          this.SignCountdata = res.result ? res.result : {}
          this.loading = false
        } else {
          this.$message.warn(res.message)
          this.loading = false
        }
      })
        .catch((e) => {
          this.loading = false
          this.$message.warn('请求失败！')
        })
    },
    getData1() {
      let obj = {
        a1: this.Urinedata.shouldNum,
        a2: this.Urinedata.actualNum,
        a3: this.Urinedata.exemptNum,
        a4: this.Urinedata.cancelNum,
        a5: this.Urinedata.ratio
      }
      let str = ""
      let objStr = JSON.stringify(obj).replace(/\"/g, "")//去掉双引号
      str = objStr.substr(1) //删除第一个字符
      str = str.substr(0, str.length - 1) //删除最后一个字符
      return str
    },
    getData2() {
      let obj = {
        a1: this.Urinedata1.shouldNum,
        a2: this.Urinedata1.actualNum,
        a3: this.Urinedata1.exemptNum,
        a4: this.Urinedata1.cancelNum,
        a5: this.Urinedata1.ratio
      }
      let str = ""
      let objStr = JSON.stringify(obj).replace(/\"/g, "")//去掉双引号，否则带反斜杠
      str = objStr.substr(1) //删除第一个字符
      str = str.substr(0, str.length - 1) //删除最后一个字符
      return str
    },
    getData3() {
      let obj = {
        a1: this.Interviewdata.shouldNum,
        a2: this.Interviewdata.actualNum,
        a3: this.Interviewdata.exemptNum,
        a4: this.Interviewdata.cancelNum,
        a5: this.Interviewdata.ratio
      }
      let str = ""
      let objStr = JSON.stringify(obj).replace(/\"/g, "")//去掉双引号，否则带反斜杠
      str = objStr.substr(1) //删除第一个字符
      str = str.substr(0, str.length - 1) //删除最后一个字符
      return str
    },
    getData4() {
      let obj = {
        a1: this.Reportdata.shouldNum,
        a2: this.Reportdata.actualNum,
        a3: this.Reportdata.exemptNum,
        a4: this.Reportdata.cancelNum,
        a5: this.Reportdata.aratio5
      }
      let str = ""
      let objStr = JSON.stringify(obj).replace(/\"/g, "")//去掉双引号，否则带反斜杠
      str = objStr.substr(1) //删除第一个字符
      str = str.substr(0, str.length - 1) //删除最后一个字符
      return str
    },
    getData5() {
      let obj = {
        a1: this.SignCountdata.shouldMonthSignInDays,
        a2: this.SignCountdata.actMonthSignInDays,
        a3: this.SignCountdata.exemptionDays,
        a4: this.SignCountdata.missSignInDays,
        a5: this.SignCountdata.signInRate
      }
      let str = ""
      let objStr = JSON.stringify(obj).replace(/\"/g, "")//去掉双引号，否则带反斜杠
      str = objStr.substr(1) //删除第一个字符
      str = str.substr(0, str.length - 1) //删除最后一个字符
      return str
    },
    getData6() {
      let obj = {
        a1: this.Otherdata.leaveNum,
        a2: this.Otherdata.leaveTime,
        a3: this.Otherdata.helpNum,
        a4: this.Otherdata.interviewNum,
        a5: this.Otherdata.mentalityNum,
        a6: this.Otherdata.lawNum,
        a7: this.Otherdata.applyTrainNum,
        a8: this.Otherdata.joinTrainNum,
        a9: this.Otherdata.submitAspirationNum,
        a10: this.Otherdata.placementNum,
        a11: this.Otherdata.communityActiveNum,
        a12: this.Otherdata.groupActiveNum,
        a13: this.Otherdata.takeMedicineNum,
      }
      let str = ""
      let objStr = JSON.stringify(obj).replace(/\"/g, "")//去掉双引号，否则带反斜杠
      str = objStr.substr(1) //删除第一个字符
      str = str.substr(0, str.length - 1) //删除最后一个字符
      return str
    }
  },
}
</script>
<style lang="less" scoped>
.titlesB{
  margin-bottom: 10px;
}
.titlesB span{
  font-size: 18px;
  font-weight: 500;
}
.titleImg{
  width: 30px;
  margin-right: 10px
}
/deep/.ant-col-5 {
  width: 24%;
  margin-right: 1.2%;
}

/deep/.ant-col-4 {
  width: 14.5%;
  margin-right: 4.5%;
}

/deep/.ant-card-body {
  padding: 10px;
}

.p1 {
  margin: 0;
  font-size: 12px;

  span {
    font-size: 18px;
    font-weight: 500;
  }
}

.p2 {
  margin-bottom: 0;

  line-height: 21.5px;

  // font-size: 12px;
  .s1 {
    color: #1890FF;
    font-size: 16px;
  }
}
</style>



